﻿using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using Borland.Studio.ToolsAPI;
using System.IO;

namespace SimpleDelphiExpert
{
    public abstract class FileHistory : IOTAFileHistory
    {
        public abstract int Count
        {
            get;
        }

        public abstract string GetAuthor(int index);
        public abstract string GetComment(int index);
        protected static void CopyStream(Stream input, Stream output)
        {
            byte[] buffer = new byte[32768];
            int read;
            while ((read = input.Read(buffer, 0, buffer.Length)) > 0)
            {
                output.Write(buffer, 0, read);
            }
        }

        protected abstract Stream DoGetContent(int index);

        public UCOMIStream GetContent(int index)
        {
            MemoryStream stream = new MemoryStream();
            CopyStream(DoGetContent(index), stream);

            return new StreamWrapper(stream);
        }

        public abstract DateTime GetDate(int index);

        public abstract TOTAHistoryStyle GetHistoryStyle(int index);

        public abstract string GetIdent(int index);

        public abstract int GetLabelCount(int index);

        public abstract string GetLabels(int index, int labelIndex);
    }
}
